package com.yulongtian.oneProblemEveryDay.month202212;

/**
 * https://leetcode.cn/problems/minimum-moves-to-convert-string/
 *
 * @author yulongTian
 * @create 2022-12-27 11:35
 */
public class Test12 {
    public static void main(String[] args) {
        System.out.println(minimumMoves("OOXXOXXXXOXX"));
    }

    public static int minimumMoves(String s) {
        char[] chars = s.toCharArray();

        int len = s.length();

        if (len == 3) {
            if (chars[0] == 'O' && chars[1] == 'O' && chars[2] == 'O') {
                return 0;
            } else {
                return 1;
            }
        }
        int ans = 0;
        for (int i = 0; i < chars.length; i++) {

            if (chars[i] == 'X') {
                for (int j = 0; i + j < len && j < 3; j++) {
                    chars[i + j] = 'O';
                }
                ans++;
            }

        }
        return ans;
    }


}
